set transaction isolation level read uncommitted

declare @t int
select @t = max(lvi_cod) from TRB_LIVRO_DIVIDA where lvi_cod > 31
--select @t 
--select * from TRB_LIVRO_DIVIDA where lvi_cod = @t
--select * from TRB_ITEM_LIVRO_DIVIDA where lvi_cod = @t

select max(ili_folha) as mxfol, count(*) as qtd from TRB_ITEM_LIVRO_DIVIDA where lvi_cod = @t
